<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:d="http://java.sun.com/jsf/composite/dip">
<h:head>
	<title></title>
</h:head>
<h:body>
	<ui:composition template="../tpt/tpt.xhtml">
		<ui:define name="head">
		Cadastro Modulo
	</ui:define>
		<ui:define name="conteudo">
			<f:view>

				<h:form prependId="false" name="formModulo" id="formModulo" lang="pt" enctype="multipart/form-data">
					<h:panelGroup id="cadCorpo" layout="block">
						<d:managerPopUp id="diego"
							urlPopUp="../listagem/listagemModulo.xhtml"
							manageBean="#{cadastroModulo}" ouvinteRendered=":formModulo:cadCorpo"
							height="420" width="550" title="Listagem Modulo"
							popUpName="listagemModulo" />
						<d:managerPopUp id="cadMenu" urlPopUp="../scu/cadMenu.xhtml"
							manageBean="#{cadastroModulo}" ouvinteRendered=":formModulo:cadCorpo"
							height="150" width="300" title="Cadastro de Menu"
							popUpName="popCadMenu" />





						<p:messages id="message" showDetail="true" autoUpdate="true" />
						<table>
							<tr>
								<td>Nome:</td>
								<td><p:inputText value="#{cadastroModulo.modulo.nome}" />
								</td>
								<td><p:commandButton id="pes" value="Pesquisar"
										update="cadCorpo"
										action="#{cadastroModulo.mostrarListagameModulos}" /></td>
							</tr>
							<tr>
								<td>URL:</td>
								<td colspan="2"><p:inputText
										value="#{cadastroModulo.modulo.url}" /></td>


							</tr>
							<tr>
								<td>Img:</td>
								<td colspan="2"><p:fileUpload
										fileUploadListener="#{cadastroModulo.handleFileUpload}" 
										mode="advanced" update="message" auto="true"
										sizeLimit="100000" allowTypes="/(\.|\/)(gif|jpe?g|png)$/" /></td>


							</tr>



						</table>
						<h:panelGroup id="barra" layout="block">
							<p:commandButton value="Salvar" update=":formModulo:cadCorpo"
								action="#{cadastroModulo.acaoInserir}"
								disabled="#{cadastroModulo.modulo.id!=null}" />
							<p:commandButton value="Alterar"
								disabled="#{cadastroModulo.modulo.id==null}" update=":formModulo:cadCorpo"
								action="#{cadastroModulo.acaoAlterar}" />
							<p:commandButton value="Excluir"
								disabled="#{cadastroModulo.modulo.id==null}" update=":formModulo:cadCorpo"
								action="#{cadastroModulo.acaoRemover}" />
							<p:commandButton value="Limpar" update="cadCorpo"
								action="#{cadastroModulo.acaoLimpar}" />


						</h:panelGroup>
						<br />

						<p:commandButton disabled="#{cadastroModulo.modulo.id==null}"
							update="cadCorpo" value="Add Menu Raiz"
							action="#{cadastroModulo.mostrarCadastroMenu}">
							<f:setPropertyActionListener target="#{cadastroModulo.mother}"
								value="#{null}" />
						</p:commandButton>
						<br />
						<br />
						<p:treeTable value="#{cadastroModulo.root}" var="menu">
							<p:column>
								<f:facet name="header">  
					                Menu  
					            </f:facet>
								<h:outputText value="#{menu.descricao}" />
							</p:column>
							<p:column>
								<f:facet name="header">  
					                Op  
					            </f:facet>
								<p:commandButton update=":formModulo:cadCorpo"
									rendered="#{menu.tipoMenu == 0 }" value="Sub Menu"
									action="#{cadastroModulo.mostrarCadastroMenu}">
									<f:setPropertyActionListener target="#{cadastroModulo.mother}"
										value="#{menu}" />
								</p:commandButton>
								<p:commandButton value="Func" rendered="#{menu.tipoMenu == 0 }"
									action="#{cadastroModulo.mostrarCadastroMenuFolha}"
									update=":formModulo:cadCorpo">
									<f:setPropertyActionListener target="#{cadastroModulo.mother}"
										value="#{menu}" />
								</p:commandButton>
								<p:commandButton value="Exc" rendered="#{menu.tipoMenu == 0 }"
									action="#{cadastroModulo.removerMenu}" update=":formModulo:cadCorpo">
									<f:setPropertyActionListener target="#{cadastroModulo.mother}"
										value="#{menu}" />
								</p:commandButton>

								<p:commandButton update=":formModulo:cadCorpo" value="Alt"
									action="#{cadastroModulo.alterarMenu}">
									<f:setPropertyActionListener target="#{cadastroModulo.mother}"
										value="#{menu}" />
								</p:commandButton>
								<p:commandButton value="Exc" rendered="#{menu.tipoMenu == 1 }"
									action="#{cadastroModulo.removerMenuFolha}" update=":formModulo:cadCorpo">
									<f:setPropertyActionListener target="#{cadastroModulo.mother}"
										value="#{menu}" />
								</p:commandButton>

							</p:column>
						</p:treeTable>
					</h:panelGroup>
				</h:form>

			</f:view>
		</ui:define>
	</ui:composition>
</h:body>
</html>
